import decimal
import datetime
import json

class DecimalEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, decimal.Decimal):
            return float(o)
        elif isinstance(o, datetime.datetime):
            return o.strftime('%Y-%m-%d %H:%M:%S')
        # else:
        #     return json.JSONEncoder.default(self, o)
        super(DecimalEncoder, self).default(o)
